/* SmartUI Studio - 项目页面样式 */

/* 编辑工具栏 */
.edit-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    padding: 0 16px;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 900;
}

.edit-toolbar-left, .edit-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.separator {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 8px;
}

.device-select {
    width: 180px;
}

/* 项目容器 */
.project-container {
    display: grid;
    grid-template-columns: 40px auto 1fr 360px 40px; /* 左侧菜单栏 左侧面板 流程编辑器/设备桌面 右侧面板 右侧菜单栏 */
    height: calc(100vh - var(--header-height) - 50px);
    margin-top: calc(var(--header-height) + 50px);
}

/* 左侧菜单栏 */
.left-sidebar {
    background-color: #f8f9fa;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--gray-color);
    margin-bottom: 8px;
    cursor: pointer;
    position: relative;
}

.sidebar-btn i {
    font-size: 20px;
}

.sidebar-btn span {
    font-size: 9px;
    margin-top: 2px;
}

.sidebar-btn.active {
    color: var(--primary-color);
}

.sidebar-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background-color: var(--primary-color);
    border-radius: 0 3px 3px 0;
}

/* 左侧面板 */
.left-panel {
    background-color: white;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    width: 0;
    transition: width 0.3s ease;
}

/* 面板标题可折叠样式 */
.panel-header.collapsible {
    cursor: pointer;
}

.panel-header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header .collapse-icon {
    margin-right: 8px;
    transition: transform 0.3s;
    font-size: 14px;
    color: var(--gray-color);
}

.panel-header[aria-expanded="false"] .collapse-icon {
    transform: rotate(-90deg);
}

.panel-header .header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding-left: 70px;
}

.panel-header .add-btn,
.panel-header .refresh-btn {
    padding: 2px 5px;
    font-size: 12px;
    background: none;
    /* border: none; */
    color: var(--gray-color);
    cursor: pointer;
}

.panel-header .add-btn i,
.panel-header .refresh-btn i {
    font-size: 10px;
}

.left-panel.expanded {
    width: 240px;
}

.panel-content {
    display: none;
    height: 100%;
    flex-direction: column;
    width: 240px;
}

.panel-content.active {
    display: flex;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    position: relative;
    height: calc(100vh - var(--header-height) - 50px - 41px); /* 减去头部高度、工具栏高度和面板头部高度 */
}

#ai-panel .panel-body {
    padding-bottom: 60px; /* 为AI输入框留出空间 */
}

/* 文件树 */
.file-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-tree ul {
    list-style: none;
    padding-left: 20px;
}

.file-tree li {
    padding: 4px 0;
}

.file-tree li span {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.file-tree li span:hover {
    background-color: var(--hover-color);
}

.file-tree li.active > span {
    background-color: var(--hover-color);
    color: var(--primary-color);
}

.file-tree li span i {
    margin-right: 6px;
}

.file-tree .folder i {
    color: #f9ab00;
}

.file-tree .file i {
    color: var(--gray-color);
}

/* 错误列表 */
.error-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.error-item {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.error-type {
    color: #f44336;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.error-type i {
    margin-right: 6px;
}

.error-message {
    margin: 4px 0;
}

.error-location {
    font-size: 12px;
    color: var(--gray-color);
}

/* 历史列表 */
.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-item {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.history-time {
    font-size: 12px;
    color: var(--gray-color);
}

.history-user {
    font-weight: 500;
    margin: 4px 0;
}

/* 内容区域 */
.content-area {
    grid-column: 3;
    display: flex;
    background-color: #f8f9fa;
    overflow: hidden;
    justify-content: center; /* 水平居中内容 */
}

/* 流程编辑器 */
.flow-editor {
    padding: 20px;
    overflow-y: auto;
    background-color: #f8f9fa;
    flex: 1;
}

.flow-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 100px;
}

.step-block {
    width: 300px;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: var(--primary-color);
    color: white;
}

.step-title {
    font-weight: 500;
}

.step-actions {
    display: flex;
    gap: 4px;
}

.step-actions .btn-link {
    color: white;
    padding: 2px;
}

.step-body {
    padding: 12px;
}

.step-param {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.param-name {
    font-weight: 500;
    color: var(--gray-color);
}

.step-connector {
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.connector-line {
    width: 2px;
    height: 100%;
    background-color: var(--border-color);
}

.add-step-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1;
}

/* 步骤选择对话框样式 */
.step-options-container {
    max-height: 300px;
    overflow-y: auto;
}

.step-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.step-option:hover {
    background-color: #f8f9fa;
    border-color: #ddd;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.step-option-icon {
    width: 40px;
    height: 40px;
    background-color: #e9ecef;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 15px;
}

.step-option-icon i {
    font-size: 1.2rem;
    color: #495057;
}

.step-option-content {
    flex: 1;
}

.step-option-content h6 {
    margin: 0 0 5px 0;
    font-weight: 500;
}

.step-option-content p {
    margin: 0;
    font-size: 0.85rem;
    color: #6c757d;
}

.step-option.hidden {
    display: none;
}

/* 设备桌面 */
.device-screen {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* 垂直居中 */
    background-color: #f8f9fa;
    border-left: 1px solid var(--border-color);
    width: 360px;
    height: 100%; /* 确保占满整个高度 */
}

.device-frame {
    width: 320px;
    height: 640px;
    background-color: white;
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 8px solid #333;
    margin: 0 auto; /* 确保在列中居中 */
    transition: width 0.3s, height 0.3s; /* 添加过渡效果 */
}

/* 当device-frame包含图片时的样式 */
.device-frame img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* 当有图片时应用此类 */
.device-frame.has-image {
    width: auto; /* 当有图片时宽度自动适应 */
    height: auto; /* 当有图片时高度自动适应 */
    max-width: 50vw; /* 最大宽度不超过屏幕宽度的一半 */
    max-height: calc(100vh - var(--header-height) - 50px - 80px); /* 确保不会太高 */
    margin: auto; /* 确保在容器中完全居中 */
}

.device-status-bar {
    height: 24px;
    background-color: #333;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    font-size: 12px;
}

.status-right {
    display: flex;
    gap: 6px;
}

.device-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.app-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.app-header {
    padding: 16px;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
}

.app-header h3 {
    margin: 0;
    font-size: 18px;
}

.app-body {
    flex: 1;
    padding: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.device-navigation {
    height: 48px;
    background-color: #333;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.device-controls {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

/* 右侧菜单栏 */
.right-sidebar {
    background-color: #f8f9fa;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    grid-column: 5; /* 设置右侧菜单栏在第5列 */
}

/* 右侧面板 */
.right-panel {
    background-color: white;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    width: 0;
    transition: width 0.3s ease;
    grid-column: 4; /* 设置右侧面板在第4列 */
}

.right-panel.expanded {
    width: 360px;
}

/* 确保右侧面板内容适应面板宽度 */
.right-panel .panel-content {
    width: 100%; /* 使面板内容宽度适应右侧面板 */
    max-width: 360px; /* 最大宽度与右侧面板一致 */
}

/* 当右侧面板收起时，调整网格布局 */
.project-container.right-collapsed {
    grid-template-columns: 40px auto 1fr 0 40px; /* 右侧面板收起时宽度为0 */
}

/* 控制台输出 */
.console-output {
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    width: 100%; /* 确保宽度适应面板 */
    overflow-x: auto; /* 允许水平滚动，防止内容溢出 */
}

.console-line {
    padding: 2px 0;
    word-break: break-word; /* 确保长文本能够换行 */
}

.console-line.error {
    color: #f44336;
}

.timestamp {
    color: var(--gray-color);
}

/* AI聊天 */
.ai-chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 0;
    height: calc(100% - 60px);
    overflow-y: auto;
    padding-bottom: 12px;
    width: 100%; /* 确保宽度适应面板 */
}

.ai-message, .user-message {
    display: flex;
    gap: 8px;
    max-width: 80%;
    width: fit-content; /* 使消息宽度适应内容 */
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-avatar, .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--hover-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar {
    color: var(--primary-color);
}

.user-avatar {
    color: var(--secondary-color);
}

.ai-content, .user-content {
    background-color: var(--hover-color);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
}

.user-content {
    background-color: var(--primary-color);
    color: white;
}

.ai-input {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--border-color);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 360px; /* 确保不超过右侧面板宽度 */
    background-color: white;
    box-sizing: border-box;
}

/* 日志输出 */
.log-output {
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    width: 100%; /* 确保宽度适应面板 */
    overflow-x: auto; /* 允许水平滚动，防止内容溢出 */
}

.log-line {
    padding: 2px 0;
    word-break: break-word; /* 确保长文本能够换行 */
}

.log-level {
    font-weight: bold;
}

.log-line.info .log-level {
    color: var(--primary-color);
}

.log-line.debug .log-level {
    color: var(--gray-color);
}

.log-line.error .log-level {
    color: #f44336;
}

/* 项目路径 */
.project-path {
    display: flex;
    align-items: center;
}

.separator {
    margin: 0 8px;
    color: var(--gray-color);
}

.path {
    color: var(--gray-color);
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .project-container {
        grid-template-columns: 40px auto 1fr 360px 40px;
    }
    
    .device-screen {
        display: none;
    }
}

@media (max-width: 1200px) {
    .content-area {
        flex-direction: column;
    }
    
    .device-screen {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

@media (max-width: 992px) {
    .project-container {
        grid-template-columns: 40px 1fr 40px;
    }
    
    .left-panel.expanded {
        position: absolute;
        left: 40px;
        top: calc(var(--header-height) + 50px);
        bottom: 0;
        width: 240px;
        z-index: 800;
    }
    
    .right-panel.expanded {
        position: absolute;
        right: 40px;
        top: calc(var(--header-height) + 50px);
        bottom: 0;
        width: 300px;
        z-index: 800;
    }
}